#include"comm.hpp"

int main()
{
    std::cout << "client begin" << std::endl;
    int wfd = open(NAME_PIPE,O_WRONLY);  //在管道文件中，读端打开不会继续运行，会阻塞等待写端打开才会继续运行
    std::cout << "client end" << std::endl;

    if(wfd < 0) exit(1);

    //write
    char buffer[1024];
    while(true)
    {
        std::cout << "Please Say# ";
        fgets(buffer,sizeof(buffer),stdin);
        if(strlen(buffer) > 0)buffer[strlen(buffer)-1] = 0;
        ssize_t n = write(wfd,buffer,sizeof(buffer)-1);
        assert(n = strlen(buffer));
        (void)n;
    }

    close(wfd);
    return 0;
}